package cn.ruituo.adv2;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapTest2 {
    public static void main(String[] args) {
        Map<Pengiun,String> m=new HashMap<>();

        m.put(new Pengiun("大花",3,"帝企鹅"),"最高");
        m.put(new Pengiun("二花",2,"帝企鹅"),"最瘦");
        m.put(new Pengiun("小花",1,"小黄企鹅"),"最矮");
        m.put(new Pengiun("小花",15,"小蓝企鹅"),"游得最快");
        //
        System.out.println("--------2----map 遍历方法：");
        Pengiun[] objects = m.keySet().toArray(new Pengiun[0]);
        for(Pengiun p:objects){
            System.out.println(p+",,,"+m.get(p));
        }
        System.out.println("------3-----map 遍历方法3：");

        Set<Map.Entry<Pengiun, String>> entries = m.entrySet();
        for(Map.Entry<Pengiun, String> k:entries){
            System.out.println(k.getKey()+">>>"+k.getValue());
        }
    }
}
